/**
 * COPYRIGHT HangZhou Trustway Technology Company Limited
 * All right reserved.
 */
package com.robam.cloud.usercenter.feigner;

import com.robam.cloud.common.bean.restful.entity.RespMsg;
import com.robam.cloud.common.bean.usercenter.entity.LoginAccount;
import com.robam.cloud.common.bean.usercenter.entity.User;
import com.robam.cloud.common.bean.usercenter.entity.UserSession;
import com.robam.cloud.log.annotation.OperationLogRecord;
import com.robam.cloud.usercenter.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description
 * @Author 薛铁琪
 * @CreateTime 2020/7/20 21:53
 * @Version 1.0
 */

@RestController
@RequestMapping("/feign/userCenter")
public class UserFeigner {
    @Autowired
    UserService userService;
    @Autowired
    HttpServletRequest httpServletRequest;

    @ApiOperation(
            value = "三方登陆初始化账号实名信息",
            notes = "三方登陆初始化账号实名信息")
    @OperationLogRecord(
            describe = "三方登陆初始化账号实名信息",
            modularCode = "/feign/userCenter/initAccountUser",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/initAccountUser",
            method = RequestMethod.POST)
    public RespMsg<LoginAccount> initAccountUser(@RequestBody UserSession userSession) {
        return RespMsg.success(userService.initAccountUser(userSession));
    }


    @ApiOperation(
            value = "判断是否实名",
            notes = "判断是否实名")
    @OperationLogRecord(
            describe = "判断是否实名",
            modularCode = "/feign/userCenter/realVerify",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/realVerify",
            method = RequestMethod.GET)
    public RespMsg<Boolean> realVerify(@RequestParam Long loginAccountId) {
        return RespMsg.success(userService.realVerify(loginAccountId));
    }


    @ApiOperation(
            value = "根据token查询user信息",
            notes = "根据token查询user信息")
    @OperationLogRecord(
            describe = "根据token查询user信息",
            modularCode = "/feign/userCenter/queryUser",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/queryUser",
            method = RequestMethod.GET)
    public RespMsg<User> queryUser(@RequestParam Long loginAccountId) {
        return RespMsg.success(userService.queryUserByAccountId(loginAccountId));
    }

    @ApiOperation(
            value = "根据token查询loginAccount信息",
            notes = "根据token查询loginAccount信息")
    @OperationLogRecord(
            describe = "根据token查询loginAccount信息",
            modularCode = "/feign/userCenter/queryLoginAccount",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/queryLoginAccount",
            method = RequestMethod.GET)
    public RespMsg<LoginAccount> queryLoginAccount(@RequestParam Long loginAccountId) {
        return RespMsg.success(userService.queryLoginAccountByAccountId(loginAccountId));
    }

    @ApiOperation(
            value = "关注",
            notes = "关注")
    @OperationLogRecord(
            describe = "关注",
            modularCode = "/feign/userCenter/subscribeEvent",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/subscribeEvent",
            method = RequestMethod.GET)
    public RespMsg subscribeEvent(@RequestParam String wechatOpenId) {
        userService.subscribeEvent(wechatOpenId);
        return RespMsg.success();
    }


    @ApiOperation(
            value = "取消关注",
            notes = "取消关注")
    @OperationLogRecord(
            describe = "取消关注",
            modularCode = "/feign/userCenter/unSubscribeEvent",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/unSubscribeEvent",
            method = RequestMethod.GET)
    public RespMsg unSubscribeEvent(@RequestParam String wechatOpenId) {
        userService.unSubscribeEvent(wechatOpenId);
        return RespMsg.success();
    }
}
